<?php

/**
 * UploadedMaterial filter form base class.
 *
 * @package    Amman to London
 * @subpackage filter
 * @author     Adel Abu-Saif <adeljas@msn.com>
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseUploadedMaterialFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'local_file'    => new sfWidgetFormFilterInput(),
      'url'           => new sfWidgetFormFilterInput(),
      'file_name'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'description'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'material_type' => new sfWidgetFormChoice(array('choices' => array('' => '', 'course pack' => 'course pack'))),
      'author'        => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'faculty'       => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'university'    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'created_at'    => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
    ));

    $this->setValidators(array(
      'local_file'    => new sfValidatorPass(array('required' => false)),
      'url'           => new sfValidatorPass(array('required' => false)),
      'file_name'     => new sfValidatorPass(array('required' => false)),
      'description'   => new sfValidatorPass(array('required' => false)),
      'material_type' => new sfValidatorChoice(array('required' => false, 'choices' => array('course pack' => 'course pack'))),
      'author'        => new sfValidatorPass(array('required' => false)),
      'faculty'       => new sfValidatorPass(array('required' => false)),
      'university'    => new sfValidatorPass(array('required' => false)),
      'created_at'    => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('uploaded_material_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'UploadedMaterial';
  }

  public function getFields()
  {
    return array(
      'id'            => 'Number',
      'local_file'    => 'Text',
      'url'           => 'Text',
      'file_name'     => 'Text',
      'description'   => 'Text',
      'material_type' => 'Enum',
      'author'        => 'Text',
      'faculty'       => 'Text',
      'university'    => 'Text',
      'created_at'    => 'Date',
    );
  }
}
